<template>
<div class='page'>
  <div class='nav'>
    <div class="input_view flex_ac" @click="$back() ">
      <van-icon class="ml6" name="arrow-left" size="26" color="#000"/>
      <div class="nav_title">成武新闻</div>
      <img class="mla mr10" width="22px" height="22px" src="~@/assets/img/xiangxian/search.png" alt="">
    </div>
    <!-- <div class="h15"></div>
    <Shaixuan :isCity="true" :isChain="true" :isNews="true" @changeInit="changeInit" />
    <div class="h15"></div> -->
	</div>
  <div class="h50"></div>
  <div class="total">为您找到 <span style="color: #FA8A26;">{{ total }}</span> 条</div>
  <div class="box_div"  ref="gun">
    <van-list
      v-model="isLoad"
      :finished="isfinish"
      finished-text="没有更多了"
      @load="getMore">
      <div v-if="list.length>0" class="item_big" @click="toDetail(list[0].id)">
        <div class="item_title text_line">{{list[0].title}}</div>
        <img class="big_img mt15" :src="list[0].img" alt="">
        <div class="item_b mt10 flex_sb">
          <div>{{list[0].from}}</div>
          <div>{{ list[0].create_time }}</div>
        </div>
      </div>

      <div class="item_small flex" v-for="i,k in list" :key="k" v-show="k!=0" @click="toDetail(i.id)">
        <div class="item_img_div">
          <img v-if="!i.isErr" class="item_img" @error="i.isErr=true;$forceUpdate()" :src="i.img" alt="">
          <img v-else class="item_img" src="https://wan3.parkic.com/company_logo/22.png" alt="">
        </div>
        <div class="item_info">
          <div class="item_title text_line">{{i.title}}</div>
          <div class="item_chain mt10 mb7">{{ i.chain_names.split(',')[0]||'-' }}</div>
          <div class="item_b flex_sb">
            <div>{{i.from}}</div>
            <div>{{i.create_time}}</div>
          </div>
        </div>
      </div>
    </van-list>
  </div>
</div>
</template>
<script>
import Shaixuan from '@/components/Shaixuan.vue'
import { news } from '@/api/api.js'
export default {
  components: {
    Shaixuan
  },
  data() {
    return {
      typeList: [
        {name:'推荐项目',id:'1'},
        {name:'投资项目',id:'2'},
        {name:'融资项目',id:'3'},
      ],
      type_id:1,
      total: 0,
      page: 1,
      isfinish: false,
      isLoad: true,
      list:[]
    }
  },
  created() {
    this.init()
  },
  methods: {
    changeInit(query) {
      this.query = query
      this.init()
    },
    init() {
      this.page = 1
      this.isfinish = false
      this.isLoad = true
      this.list = []
      this.getList()
    },
    getMore() {
      if (this.isfinish||this.list.length==0) {
        return
      }
      this.page++
      this.getList()
    },
    getList() {
      let data = {
        page: this.page,
        city_id: 2380,
        ...this.query
      }
      news.getList({...data}).then(res => {
        this.isLoad = false
        this.list.push(...res.data.data)
        this.total = res.data.total
        if (this.list.length >= this.total) {
          this.isfinish = true
        }
      })
    },
    toDetail(id) {
      this.$router.push({name: 'newsDetail', query: {id}})
    }
  }
}
</script>
<style lang="scss" scoped>
.nav{
	width: 100%;
	position: fixed;
	top: 0;
	left: 0;
	background-color: rgba($color: #fff, $alpha: 1);
	z-index: 10;
	transition: all 0.5s;
}
.input_view{
	width: 100%;
  height: 40px;
	.nav_title{
		font-weight: 500;
		font-size: 18px;
		color: #000;
	}
}

.page{
	height:100%;
	width:100%;
	background: #F4F4F4;;
  .total{
    margin-left: 10px;
    font-size: 10px;
    color: #333333;
  }
}
.box_div{
  // margin: 0 10px 10px;
  // padding: 10px;
  // background: #FFFFFF;
  // box-shadow: 0px 3px 9px 2px rgba(250,135,30,0.13);
  // border-radius: 4px 4px 4px 4px;
  height: calc(100% - 115px);
  overflow: auto;
  .item_div{
    background: #FFFFFF;
    box-shadow: 0px 3px 9px 2px rgba(68,142,238,0.13);
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
    position: relative;
    margin: 10px 5px;
    .item_img_div{
      width: 100%;
      position: relative;
      .item_img{
        width: 100%;
        display: block;
        height: auto !important;
      }
    }
    .item_title{
      font-size: 14px;
      color: #333333;
      width: calc(100% - 20px);
      margin: 10px 10px 5px 10px;
    }
    .item_desc{
      width: calc(100% - 20px);
      font-size: 10px;
      color: #999999;
      margin: 0px 10px 10px 10px;
    }
  }
}

.type_item{
  height: 24px;
  line-height: 24px;
  background: #F5F5F5;
  border-radius: 12px;
  font-size: 13px;
  color: #000000;
  padding: 0 10px;
  margin-right: 10px;
  width: fit-content;
  display: inline-block;
  position: relative;
  top: -1px;
}
.type_item_a{
  background: #FA8A2622;
  color: #FA8A26;
}

.item_big{
  margin: 10px;
  background: #FFFFFF;
  border-radius: 5px;
  box-shadow: 0px 2px 3px 0px rgba(24,27,37,0.06);
  padding: 15px 10px;
}
.item_title{
  font-weight: 500;
  font-size: 15px;
  color: #000000;
}
.item_chain{
  height: 16px;
  background: rgba(250,138,38,0.1);
  border-radius: 3px;
  line-height: 16px;
  padding: 0 5px;
  color: #FA8A26;
  font-size: 11px;
  width: fit-content;
}
.big_img{
  width: 100%;
  border-radius: 5px;
}
.item_b{
  font-size: 13px;
  color: #666666;
}
.item_small{
  margin: 10px;
  background: #FFFFFF;
  border-radius: 5px;
  box-shadow: 0px 2px 3px 0px rgba(24,27,37,0.06);
  padding: 15px 10px;
  .item_img{
    width: 110px;
    height: 70px;
    margin-right: 10px;
    display: block;
  }
  .item_info{
    width: calc(100% - 120px);
  }
}
</style>